<?php

namespace App\Utils\Weixin;
/**
 * Created by PhpStorm.
 * User: chenlingguang
 * Date: 16/5/4
 * Time: 下午4:57
 */

use Illuminate\Support\Facades\Redis;

class WechatRedisCache extends Wechat
{
    protected function getCache($cachename) {
        try {
            return Redis::connection('')->get($cachename);
        } catch (\Exception $e) {
            return Redis::connection('')->get($cachename);
        }
    }

    protected function setCache($cachename, $value, $expire = 0) {
        if (is_int($expire) && $expire) {
            $result = Redis::connection('')->setex($cachename, $expire, $value);
        } else {
            $result = Redis::connection('')->set($cachename, $value);
        }
        return $result;
    }

    protected function removeCache($cachename) {
        return Redis::connection('')->set($cachename, null);
    }
}